#pragma warning(disable:4996)

#include <stdio.h>
#include <limits.h>
#include <float.h>
#include <memory.h>
#include <math.h>

static const float time1 = 60.0 / 10000;
static const float time2 = 60.0 / 40000;

struct Pos
{
	int x, y;
	float operator-(const Pos& rhs)
	{
		return sqrt((float)((x - rhs.x) * (x - rhs.x) + (y - rhs.y) * (y - rhs.y)));
	}
};

float G[202][202];
Pos V[202];
short visited[202];

int ShortestPath(int size)
{
	memset(visited, 0, sizeof(visited));
	while (1)
	{
		int k = 0;
		G[0][0] = FLT_MAX;
		for (int i = 1; i < size; i++)
		{
			if (G[0][i] < G[0][k] && visited[i] == 0)
			{
				k = i;
			}
		}
		if (k == 0)
			break;

		visited[k] = 1;
		for (int i = 1; i < size; i++)
		{
			float dis = G[0][k] + G[k][i];
			if (dis < G[0][i])
				G[0][i] = dis;
		}
	}
	int time = G[0][1];
	if (G[0][1] - time < 0.5)
		return time;
	else
		return time + 1;
}

int main()
{
	Pos start, end;
	while (scanf("%d %d", &start.x, &start.y) != EOF)
	{
		int index = 0;
		V[index++] = start;
		scanf("%d %d", &end.x, &end.y);
		V[index++] = end;
		G[0][1] = G[1][0] = (start - end) * time1;

		while (1)
		{
			Pos pos;
			scanf("%d %d", &pos.x, &pos.y);
			if (pos.x == -1 && pos.y == -1)
				break;

			for (int i = 0; i < index; i++)
				G[i][index] = G[index][i] = (pos - V[i]) * time1;
			G[index][index] = 0;
			V[index++] = pos;

			while (1)
			{
				Pos pos;
				scanf("%d %d", &pos.x, &pos.y);
				if (pos.x == -1 && pos.y == -1)
					break;

				G[index][index] = 0;
				for (int i = 0; i < index; i++)
				{
					G[i][index] = G[index][i] = (pos - V[i]) * time1;
				}
				G[index - 1][index] = G[index][index - 1] = (pos - V[index - 1]) * time2;
				V[index++] = pos;
			}
		}

		printf("%d\n", ShortestPath(index));

	}
}